package com.android.monee.binding.observer;

import com.android.monee.binding.Field;

public abstract class AbstractObserverImpl<S, T, V> implements Observer<S, T, V>{

	private Field<S, V> sourceField;
	private T target;
	
	public AbstractObserverImpl(Field<S, V> sourceField, T target){
		this.sourceField = sourceField;
		this.target = target;
	}
	
	@Override
	public void updateTarget(S observableSource) {
		updateTarget(this.target, sourceField.get(observableSource));
	}

	@Override
	public abstract void updateTarget(T target, V newVal);
	
	@Override
	public Field<S, V> getSourceField(){
		return this.sourceField;
	}
}
